function createCounter() {
    let  n = 0
    return function fn(){
        n++
        return n; 
    }    
}
const counter = createCounter();

console.log(counter()); // 1
console.log(counter()); // 2
console.log(counter()); // 3